package com.keyancompany.zhongbaopingtai.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;

import com.keyancompany.zhongbaopingtai.R;
import com.keyancompany.zhongbaopingtai.model.DummyItem;
import com.keyancompany.zhongbaopingtai.model.Weekly;


/**
 * {@link RecyclerView.Adapter} that can display a {@link DummyItem} and makes a call to the
 * TODO: Replace the implementation with code for your data type.
 */
public class WeeklyAdapter extends ListAdapter<Weekly> {

    public WeeklyAdapter(Context ctx) {
        super(ctx);
    }

    @Override
    public int getContentViewId() {
        return R.layout.item_weekly_list;
    }

    @Override
    public HolderView getHoldView(int position, View contentView, ViewGroup parent) {
        return new ViewHolder(contentView);
    }

    @Override
    public void setItemView(int position, HolderView contentView, Weekly item) {
        ViewHolder holder = (ViewHolder) contentView;
        holder.weeklyContent.setText(Html.fromHtml(item.getContent()));
        holder.name.setText("创建人:" + item.getUsername());
    }

    public class ViewHolder extends HolderView {
        public final TextView name;
        public final TextView weeklyContent;

        public ViewHolder(View view) {
            name = (TextView) view.findViewById(R.id.name);
            weeklyContent = (TextView) view.findViewById(R.id.weekly_content);
        }

        @Override
        public String toString() {
            return super.toString() + " '" + weeklyContent.getText() + "'";
        }
    }
}
